Berkeley CS 61C Lecture 22

Here are some notes and corrections on this lecture:

Each note begins with a time; "ca." in front of a time means that it is approximate.

Here's where you learn about operating systems, memory-mapped I/O (MMIO), and virtual memory. Be sure to watch this one. Pay close attention to the MMIO part, we'll do a program using that later this semester.

He uses the abbreviation ISA a number of times. This means instruction-set architecture, i.e. the instructions that your machine can execute. The ISA that we use in this course is MIPS, which is very different from Intel.

ca. 32:00 -- back in the good old days, we didn't have ROM; instead, we toggled in a small program in binary by hand (1 bit at a time) and ran that to get things going.

ca. 40:00 -- MIPS calls supervisor mode kernel mode. See page A-35 in the book. Bit 4 in Figure A.7.1 is labeled "user mode". It this bit is off (i.e. 0) then the CPU is in kernel mode.

ca. 42:20 -- MARS simulates some syscalls; we'll get to that soon.

ca. 44:30 -- (question) My favorite example of this is that, as a user, you can ask the OS to open a particular file for reading. The OS will check that there is such a file and that you have permission to read it. If you pass that test, it will look up in its directory and find which disk blocks contain the bits of the file and leave things ready for you to make further syscalls to read bits from the file. This is very different from allowing you to read whatever disk blocks you like, which is what the disk controller itself would do if you had direct access to it. This is what he means by "mediate".

47:55 -- When he says "current stack" he means the stack pointer. You also need to save the PC and $1 - $31. What gets saved is called the process's state.

ca. 53:00 -- The book says "virtual address" where he says "dynamic address". The slide at 55:40 calls it "logical address"; it's all the same thing: the address that the program thinks it's using. It is really somewhere else, and the hardware takes care of the mapping to the right physical address. This example of base-and-bound translation that he's talking about here is not what is actually used in practice; it's an introductory step to explain the ideas about what we're trying to accomplish: each process thinks it has a big memory space beginning at address 0, but the memory spaces of the various processes do not overlap. Each process is constrained to operate within its own memory space and does not know the actual physical addresses that it is using; it just knows the logical addresses. Since the logical addresses begin at zero, the OS can compute the physical address simply by adding the logical address to the base register, which contains the physical address corresponding to that process's logical address zero. Back when this was invented, the fact that a process could have a bigger address space than physical memory was a big deal; these days it's not a big deal, but the other advantages remain: since the physical address spaces don't overlap, no process can interfere with another; we can build the executable image of any process to live in an address space beginning at zero. Without this, we'd have to be very careful to build all our executables so that their address spaces didn't overlap. I hope that it's obvious that this becomes impossible to do once we have a large collection of applications that may need to run at the same time.

1:01:25 -- Notice that the math here is exactly what we did for cache memory: page is like block, and offset is still offset.

1:05:00 -- The pictures in the book are pretty good replacements for the ones he lost. On page 430 they introduce the idea: the page number gets translated from virtual to physical, an the offset stays the same. On page 433, we see how the translation is done: use the virtual page number as an index into the process's page table, and the number we find there is the translation.